import React,{Component} from "react";
import { NavLink, Link, withRouter, Route, Redirect} from 'react-router-dom';
import {Button, message, Table, Input, Form, Popover, Pagination, Row, Col,  DatePicker} from "antd";
import Header from "../component/header.js";
import Company from "../utils/management/company.js";
import Plane from "../utils/management/plane.js";
import Flight from "../utils/management/flight.js";
import Ticket from "../utils/management/ticket.js";
import News from "../utils/management/news.js";
import NewsDetail from "../utils/management/newsDetail";

import Book from "../utils/management/book.js";

import '../assets/stylesheets/management.css';

const format = "YYYY-MM-DD";
class Management extends Component{
    constructor(props){
        super(props);
        this.state = {
            username:localStorage.getItem("manage"),
            UIstate:{
                nomalDisplay:"block",
                addDispaly:"none",
            },
            selectedRows:[],
        }
    }
    componentDidMount(){
        //如果管理员没有登录
        if(!this.state.username){
            this.props.history.push({ pathname:'/login' });
        }
    }
    
    existClick = (e) =>{
        localStorage.removeItem("manage");
        this.props.history.push({
            pathname:"/",
        })
    }
    render(){
        // table的数据
        const state = this.state;
        
        return(
        <div>
            <div className="header">
                <div className="h-content">
                    <div className="logo"><a><img src={require("../assets/images/logo.png")} alt=""/></a></div>
                    <Popover trigger="hover" placement="bottom" content={
                        <div>
                            <a><span className="username" onClick={this.existClick}>退出登陆</span></a>
                        </div>
                    }>
                        <div className="log-reg"><a><span>{state.username}</span></a></div>
                    </Popover>
                </div>
            </div> 
            <div className="manage-box">
                <div className="left">
                    <ul>
                        <li><NavLink to="/management/company"  activeClassName="active"><span>航空公司信息</span></NavLink></li>
                        <li><NavLink to="/management/plane"  activeClassName="active"><span>飞机信息</span></NavLink></li>
                        <li><NavLink to="/management/flight"  activeClassName="active"><span>航班信息</span></NavLink></li>
                        <li><NavLink to="/management/ticket"  activeClassName="active"><span>机票信息</span></NavLink></li>
                        <li><NavLink to="/management/news"  activeClassName="active"><span>新闻信息</span></NavLink></li>
                        <li><NavLink to="/management/book"  activeClassName="active"><span>订单信息</span></NavLink></li>
                    </ul>
                </div>
                <div className="right">
                    <Route exact path="/management/company" component={Company} />
                    <Route exact path="/management/plane" component={Plane} />
                    <Route exact path="/management/flight" component={Flight} />
                    <Route exact path="/management/ticket" component={Ticket} />
                    <Route exact path="/management/news" component={News} />
                    <Route exact path="/management/newsDetail" component={NewsDetail} />
                    <Route exact path="/management/book" component={Book} />
                    <Route exact path="/management" render={() => (<Redirect to="/management/company"/>)} />
                </div>
            </div>
        </div>)
    }
}

export default Form.create({})(withRouter(Management));